package panels;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import login.Login.*;

public class LoginPanel {
	
	public JLabel text;
	public JPanel panel;
	
	public CardLayout changeCopy;
	public JPanel middlePCopy;
	
	public LoginPanel(CardLayout change, JPanel middle)
	{
		changeCopy = change;
		middlePCopy = middle;
		
		panel = new JPanel();
		panel.setLayout(new GridLayout(3, 3));
		
		text = new JLabel("");
        panel.add(text);
        
        JLabel text2 = new JLabel("(Logo)");
        text2.setHorizontalAlignment(JLabel.CENTER);
        panel.add(text2);
        
        JLabel text3 = new JLabel("");
        panel.add(text3);
        
        JLabel text4 = new JLabel("");
        panel.add(text4);
        
        
        JPanel loginArea = new JPanel(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        
        JLabel usernameL = new JLabel("Username:");
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 2;
        c.gridx = 0;
        c.gridy = 0;
        loginArea.add(usernameL, c);
        
        JLabel fake = new JLabel("");
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 2;
        c.gridx = 1;
        c.gridy = 0;
        loginArea.add(fake, c);
        
        JLabel fake2 = new JLabel("");
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 2;
        c.gridx = 2;
        c.gridy = 0;
        loginArea.add(fake2, c);
        
        JTextField usernameTF = new JTextField();
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = 3;
        c.weightx = 2;
        c.gridx = 0;
        c.gridy = 1;
        loginArea.add(usernameTF, c);
        
        JLabel passwordL = new JLabel("Password:");
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 2;
        c.gridx = 0;
        c.gridy = 2;
        loginArea.add(passwordL, c);
        
        JTextField passwordTF = new JTextField();
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = 3;
        c.weightx = 2;
        c.gridx = 0;
        c.gridy = 3;
        loginArea.add(passwordTF, c);
        
        JButton loginB = new JButton("Login");
        loginB.addActionListener(new loginBListener());
        c.insets = new Insets(10,0,0,0);
        c.gridx = 2;
        c.gridy = 4;
        loginArea.add(loginB, c);
        
        /*
        //Input area for username and password
        JPanel loginArea = new JPanel();
        loginArea.setLayout(new GridLayout(5, 1));
        
        JLabel usernameL = new JLabel("Username:");
        loginArea.add(usernameL);
        
        JTextField usernameTF = new JTextField();
        loginArea.add(usernameTF);
        
        JLabel passwordL = new JLabel("Password:");
        loginArea.add(passwordL);
        
        JTextField passwordTF = new JTextField();
        loginArea.add(passwordTF);
        
        JButton loginB = new JButton("Login");
        loginArea.add(loginB);
        */
        
        panel.add(loginArea);
        
        
        JLabel text5 = new JLabel("");
        panel.add(text5);
        
        JLabel text6 = new JLabel("");
        panel.add(text6);
        
        JLabel text7 = new JLabel("");
        panel.add(text7);
        
        JLabel text8 = new JLabel("");
        panel.add(text8);
	}
	
	private class loginBListener implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			changeCopy.show(middlePCopy, "Welcome_Panel");
		}
	}
}
